package com.house.rent.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;

import com.base.lib.ui.dialog.BaseDialog;
import com.house.rent.R;


public class PublishDialog extends BaseDialog {

    private OnPublishListener mListener;

    public PublishDialog(Context context) {
        super(context);
    }

    public void setOnPublishListener(OnPublishListener listener) {
        this.mListener = listener;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setCancelable(true);
        setCanceledOnTouchOutside(true);
    }

    @Override
    protected View setContentView() {
        return LayoutInflater.from(getContext()).inflate(R.layout.dialog_publish, null);
    }

    @Override
    protected void initContentView(View contentView) {
        if (TextUtils.isEmpty(titleStr)) {
            titleStr = "请选择";
        }

        setTitleText(titleStr);
        btnButton.setVisibility(View.GONE);
        divider.setVisibility(View.INVISIBLE);

        contentView.findViewById(R.id.tv_publish0).setOnClickListener(v -> {
            dismiss();
            if (mListener != null) {
                mListener.onClickPlatform(PublishDialog.this, 0);
            }
        });

        contentView.findViewById(R.id.tv_publish1).setOnClickListener(v -> {
            dismiss();
            if (mListener != null) {
                mListener.onClickPlatform(PublishDialog.this, 1);
            }
        });


        contentView.findViewById(R.id.tv_publish2).setOnClickListener(v -> {
            dismiss();
            if (mListener != null) {
                mListener.onClickPlatform(PublishDialog.this, 2);
            }
        });


        contentView.findViewById(R.id.tv_publish3).setOnClickListener(v -> {
            dismiss();
            if (mListener != null) {
                mListener.onClickPlatform(PublishDialog.this, 3);
            }
        });
    }

    public interface OnPublishListener {

        void onClickPlatform(Dialog dialog, int position);
    }
}
